const http = require('http')
const path = require('path')
const fs = require('fs')
const server = http.createServer()

server.on('request',(req,res)=>{
    let url = req.url
    console.log(url);
    let fullPath =  path.join(__dirname,'client',url)
    if (url === '/'){
        fullPath = path.join(__dirname,'client','index.html')
    }
    fs.readFile(fullPath,(err,data)=>{
        if(err){
            return res.end(err.message)
        }
        return res.end(data)
    })
})

server.listen(3000,()=>{
    console.log('listen port 3000....');
})